package com.betterwood.dragon.controllers;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

import com.betterwood.dragon.core.common.JsonResult;
import com.betterwood.dragon.entity.dto.IdDTO;
import com.betterwood.dragon.utils.CodeUtil;

import org.jsoup.Jsoup;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.hutool.core.codec.Base64;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import lombok.extern.slf4j.Slf4j;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

@RestController
@RequestMapping(value = "/worm")
@CrossOrigin
// 使用Lombok自动生成注入的构造函数
@RequiredArgsConstructor
@Slf4j
public class WormController {

    @PostMapping(value = "/testVerify")
    public JsonResult<String> testVerify(@RequestBody IdDTO idDTO) {
        File imageFile = new File("/Users/helldomi/Documents/jfcode.png");
        if (!imageFile.exists()) {
            System.out.println("pic not exist");
            ;
        }
        // String resultStr = CodeUtil.decode(imageFile);
        String resultStr = "234";
        return JsonResult.success(resultStr);
    }

}
